﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// Simple Service Administration Tool for WinNT based systems.
// Copyright © 2010 - Silvan Gehrig
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
// 
// Author:
//  Silvan Gehrig
//
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.ServiceModel;

using SSATool.DL.Common.Dto;

#endregion

namespace SSATool.DL.Common
{
    /// <summary>
    /// Specifies the common client data interface.
    /// </summary>
    public interface IClientDataProvider
    {
        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Represents the an event which is fired if the data on the
        /// server has changed.
        /// </summary>
        event EventHandler<ClientDataEventArgs> Update;

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Starts the client and opens the connection in an asynchronous manner.
        /// </summary>
        /// <param name="destination">Specifies the destination host address.</param>
        /// <param name="password">Specifies the user name of the destination host which is used to log in.</param>
        /// <param name="username">Specifies the password of the destination host which is used to log in.</param>
        /// <param name="callback">Specifies the callback method which is used the operation has been completed.</param>
        void StartAsync(string destination, string username, string password, Action<Exception> callback);

        /// <summary>
        /// Starts the client and opens the connection.
        /// </summary>
        /// <param name="destination">Specifies the destination host address.</param>
        /// <param name="password">Specifies the user name of the destination host, which is used to log in.</param>
        /// <param name="username">Specifies the password of the destination host, which is used to log in.</param>
        void Start(string destination, string username, string password);

        /// <summary>
        /// Stops the client and closes the connection.
        /// </summary>
        void Stop();

        /// <summary>
        /// Gets a list of all service controllers.
        /// </summary>
        /// <returns>Returns the service list.</returns>
        IList<ServiceController> GetServiceList();

        /// <summary>
        /// Gets the service with the given unique name.
        /// </summary>
        /// <param name="uniqueServiceName">Name of the service to retrieve.</param>
        /// <returns>Returns the retrieved service.</returns>
        ServiceController GetService(string uniqueServiceName);

        /// <summary>
        /// Sends the changes on a service back to the host.
        /// </summary>
        /// <param name="service">Specifies the service to update.</param>
        void SetService(ServiceController service);

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
